#include "utilities.h"

int main()
{
	int nKey = 400;
	ShareMemory<TestData2> shareMemoryTestData(nKey);

	TestData2 &testData = shareMemoryTestData.Get();
	{
		std::lock_guard<tbb::detail::d1::spin_rw_mutex> lck(testData.m_mutex);
		testData.m_procCount++;
	}

	while (testData.m_procCount < 2)
	{
		std::this_thread::yield();
	}

	std::cout << "main run." << std::endl;

	if (testData.m_procCount >= 2)
	{
		for (int i = 0; i < 100000000; ++i)
		{
			std::lock_guard<tbb::detail::d1::spin_rw_mutex> lck(testData.m_mutex);
			testData.m_count++;
		}
	}

	std::lock_guard<tbb::detail::d1::spin_rw_mutex> lck(testData.m_mutex);
	std::cout << "testData.m_count: " << testData.m_count << std::endl;
	std::cout << "testData.m_procCount: " << testData.m_procCount << std::endl;
	return 0;
}
